package com.enterprise.support.utility;

import javax.swing.*;
import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2011-1-26
 * Time: 17:12:13
 * To change this template use File | Settings | File Templates.
 */
public class SwingUtility {

    public static void warning(String msg) {
        JOptionPane.showMessageDialog(null, msg, "提示信息", JOptionPane.WARNING_MESSAGE);
    }

    public static void info(String msg) {
        JOptionPane.showMessageDialog(null, msg, "提示信息", JOptionPane.INFORMATION_MESSAGE);
    }

    public static int confirm(String msg) {
        return JOptionPane.showConfirmDialog(null, msg, "请确定？", JOptionPane.YES_NO_OPTION);
    }

    public static void disable(Container container) {
        for (Component comp : container.getComponents()) {
            if (comp instanceof Container) {
                disable((Container) comp);
            }
            comp.setEnabled(false);
        }
    }

    public static void enable(Container container) {
        for (Component comp : container.getComponents()) {
            if (comp instanceof Container) {
                enable((Container) comp);
            }
            comp.setEnabled(true);
        }
    }
}
